import request from '../utils/request'

// 查询流程实例列表
export const queryList = (data) => {
  return request({
    method: 'POST',
    url: 'app/rest/query/process-instances',
    data: {
      ...data,
      page: 0
    }
  })
}
// 启动流程
export const createOne = (data) => {
  return request({
    method: 'POST',
    url: 'app/rest/process-instances',
    data: data
  })
}

// 取消流程
export const deleteOne = (id) => {
  return request({
    method: 'DELETE',
    url: `app/rest/process-instances/${id}`
  })
}

// 查询流程实例详情
export const queryProcessDetail = (id) => {
  return request({
    method: 'GET',
    url: `app/rest/process-instances/${id}`
  })
}

// 查询流程实例的任务
export const queryProcessTasks = (data) => {
  return request({
    method: 'POST',
    url: 'app/rest/query/tasks',
    data: data
  })
}

// 查询流程实例的评论
export const queryProcessComments = ({ pid, ...params}) => {
  return request({
    method: 'GET',
    url: `app/rest/process-instances/${pid}/comments`,
    params: params
  })
}

export const createProcessComments = ({ pid, ...data}) => {
  return request({
    method: 'POST',
    url: `app/rest/process-instances/${pid}/comments`,
    data: data
  })
}


export const queryStartForm = (processInstanceId) => {
  return request({
    method: 'GET',
    url: `app/rest/process-instances/${processInstanceId}/start-form`
  })
}